<!DOCTYPE html>
<html lang="en">
  <head>
    <title>LocalProcess Class Reference</title>
    <link rel="stylesheet" type="text/css" href="../css/jazzy.css" />
    <link rel="stylesheet" type="text/css" href="../css/highlight.css" />
    <meta charset='utf-8'>
    <script src="../js/jquery.min.js" defer></script>
    <script src="../js/jazzy.js" defer></script>
    
  </head>
  <body>
    <a name="//apple_ref/swift/Class/LocalProcess" class="dashAnchor"></a>
    <a title="LocalProcess Class Reference"></a>
    <header>
      <div class="content-wrapper">
        <p><a href="../index.html">SwiftTerm 1.0 Docs</a> (65% documented)</p>
        <p class="header-right"><a href="https://github.com/migueldeicaza/SwiftTerm"><img src="../img/gh.png"/>View on GitHub</a></p>
        <p class="header-right"><a href="dash-feed://https%3A%2F%2Fmigueldeicaza%2Egithub%2Eio%2FSwiftTerm%2Fdocsets%2FSwiftTerm%2Exml"><img src="../img/dash.png"/>Install in Dash</a></p>
      </div>
    </header>
    <div class="content-wrapper">
      <p id="breadcrumbs">
        <a href="../index.html">SwiftTerm Reference</a>
        <img id="carat" src="../img/carat.png" />
        LocalProcess Class Reference
      </p>
    </div>
    <div class="content-wrapper">
      <nav class="sidebar">
        <ul class="nav-groups">
          <li class="nav-group-name">
            <a href="../Classes.html">Classes</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Classes/Color.html">Color</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/HeadlessTerminal.html">HeadlessTerminal</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/LocalProcess.html">LocalProcess</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/LocalProcessTerminalView.html">LocalProcessTerminalView</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/PseudoTerminalHelpers.html">PseudoTerminalHelpers</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/Terminal.html">Terminal</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/Terminal/MouseMode.html">– MouseMode</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/Terminal/WindowManipulationCommand.html">– WindowManipulationCommand</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/TerminalAccessory.html">TerminalAccessory</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/TerminalDebugView.html">TerminalDebugView</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/TerminalView.html">TerminalView</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/TerminalView/Font.html">– Font</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/TerminalView.html">TerminalView</a>
              </li>
              <li class="nav-group-task">
                <a href="../Classes/TerminalView/Font.html">– Font</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Enums.html">Enumerations</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Enums/CursorStyle.html">CursorStyle</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Extensions.html">Extensions</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Extensions/TerminalViewDelegate.html">TerminalViewDelegate</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Protocols.html">Protocols</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Protocols/LocalProcessDelegate.html">LocalProcessDelegate</a>
              </li>
              <li class="nav-group-task">
                <a href="../Protocols/LocalProcessTerminalViewDelegate.html">LocalProcessTerminalViewDelegate</a>
              </li>
              <li class="nav-group-task">
                <a href="../Protocols/TerminalDelegate.html">TerminalDelegate</a>
              </li>
              <li class="nav-group-task">
                <a href="../Protocols/TerminalViewDelegate.html">TerminalViewDelegate</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Structs.html">Structures</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Structs/Attribute.html">Attribute</a>
              </li>
              <li class="nav-group-task">
                <a href="../Structs/Attribute/Color.html">– Color</a>
              </li>
              <li class="nav-group-task">
                <a href="../Structs/CharData.html">CharData</a>
              </li>
              <li class="nav-group-task">
                <a href="../Structs/CharacterStyle.html">CharacterStyle</a>
              </li>
              <li class="nav-group-task">
                <a href="../Structs/TerminalOptions.html">TerminalOptions</a>
              </li>
              <li class="nav-group-task">
                <a href="../Structs/TinyAtom.html">TinyAtom</a>
              </li>
            </ul>
          </li>
          <li class="nav-group-name">
            <a href="../Typealiases.html">Type Aliases</a>
            <ul class="nav-group-tasks">
              <li class="nav-group-task">
                <a href="../Typealiases.html#/s:9SwiftTerm7TTImagea">TTImage</a>
              </li>
            </ul>
          </li>
        </ul>
      </nav>
      <article class="main-content">
        <section>
          <section class="section">
            <h1>LocalProcess</h1>
              <div class="declaration">
                <div class="language">
                  <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">class</span> <span class="kt">LocalProcess</span></code></pre>

                </div>
              </div>
            <p>This class provides the capabilities to launch a local Unix process, and connect it to a <code><a href="../Classes/Terminal.html">Terminal</a></code>
 class or subclass.</p>

<p>The <code>MacLocalTerminalView</code> is an example of this, it is a subclass of the
 <code>MacTerminalView</code> NSView, and it connects that view to the local system, providing a complete
 terminal emulator connected to running local commands.</p>

<p>When you create an instance of <code>LocalProcess</code>, you provide a delegate that is used to notify
 your application when data is received from the lcoal process, to request the desired window size
 that you would like to give to the child process, and when the process terminates.</p>

<p>Once you create this instance, you can start a child process by calling the <code>startProcess</code> method
 which will start the process.   You can then send data to this underlying process using the
 <code>send(data:)</code> method, and you will receive the output on the provided delegate with the
 <code>dataReceived(slice:)</code> method.</p>

<p>Received data is dispatched via the queue that you provide in the LocalProcess constructor, if none
 is provided, this will default to <code>DispatchQueue.main</code>.  Generally, this is a good default, but if you
 have your own main loop or a different dispatching system, you will need to pass your own (for example,
 the <code><a href="../Classes/HeadlessTerminal.html">HeadlessTerminal</a></code> implementation in the test suite does this.</p>

          </section>
          <section class="section task-group-section">
            <div class="task-group">
              <ul>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:9SwiftTerm12LocalProcessC8delegate13dispatchQueueAcA0cD8Delegate_p_So03OS_F6_queueCSgtcfc"></a>
                    <a name="//apple_ref/swift/Method/init(delegate:dispatchQueue:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:9SwiftTerm12LocalProcessC8delegate13dispatchQueueAcA0cD8Delegate_p_So03OS_F6_queueCSgtcfc">init(delegate:<wbr>dispatchQueue:<wbr>)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Initializes the LocalProcess runner and communication with the host happens via the provided
<code><a href="../Protocols/LocalProcessDelegate.html">LocalProcessDelegate</a></code> instance.</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="nf">init</span><span class="p">(</span><span class="nv">delegate</span><span class="p">:</span> <span class="kt"><a href="../Protocols/LocalProcessDelegate.html">LocalProcessDelegate</a></span><span class="p">,</span> <span class="nv">dispatchQueue</span><span class="p">:</span> <span class="kt">DispatchQueue</span><span class="p">?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>delegate</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>the delegate that will receive events or request data from your application</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>dispatchQueue</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>this is the queue that will be used to post data received from the
child process when calling the <code>send(dataReceived:)</code> delegate method.  If the value provided is <code>nil</code>,
then this will default to <code>DispatchQueue.main</code></p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/migueldeicaza/SwiftTerm/tree/master/Sources/SwiftTerm/LocalProcess.swift#L76-L80">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:9SwiftTerm12LocalProcessC4send4datays10ArraySliceVys5UInt8VG_tF"></a>
                    <a name="//apple_ref/swift/Method/send(data:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:9SwiftTerm12LocalProcessC4send4datays10ArraySliceVys5UInt8VG_tF">send(data:<wbr>)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Sends the array slice to the local process using DispatchIO</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">send</span><span class="p">(</span><span class="nv">data</span><span class="p">:</span> <span class="kt">ArraySlice</span><span class="o">&lt;</span><span class="kt">UInt8</span><span class="o">&gt;</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>data</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The range of bytes to send to the child process</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/migueldeicaza/SwiftTerm/tree/master/Sources/SwiftTerm/LocalProcess.swift#L86-L111">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:9SwiftTerm12LocalProcessC05startD010executable4args11environmentySS_SaySSGAHSgtF"></a>
                    <a name="//apple_ref/swift/Method/startProcess(executable:args:environment:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:9SwiftTerm12LocalProcessC05startD010executable4args11environmentySS_SaySSGAHSgtF">startProcess(executable:<wbr>args:<wbr>environment:<wbr>)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Launches a child process inside a pseudo-terminal</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">startProcess</span><span class="p">(</span><span class="nv">executable</span><span class="p">:</span> <span class="kt">String</span> <span class="o">=</span> <span class="s">"/bin/bash"</span><span class="p">,</span> <span class="nv">args</span><span class="p">:</span> <span class="p">[</span><span class="kt">String</span><span class="p">]</span> <span class="o">=</span> <span class="p">[],</span> <span class="nv">environment</span><span class="p">:</span> <span class="p">[</span><span class="kt">String</span><span class="p">]?</span> <span class="o">=</span> <span class="kc">nil</span><span class="p">)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>executable</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>The executable to launch inside the pseudo terminal, defaults to /bin/bash</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>args</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>an array of strings that is passed as the arguments to the underlying process</p>
                                </div>
                              </td>
                            </tr>
                            <tr>
                              <td>
                                <code>
                                <em>environment</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>an array of environment variables to pass to the child process, if this is null, this picks a good set of defaults from <code>Terminal.getEnvironmentVariables</code>.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/migueldeicaza/SwiftTerm/tree/master/Sources/SwiftTerm/LocalProcess.swift#L170-L203">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
                <li class="item">
                  <div>
                    <code>
                    <a name="/s:9SwiftTerm12LocalProcessC14setHostLogging9directoryySSSg_tF"></a>
                    <a name="//apple_ref/swift/Method/setHostLogging(directory:)" class="dashAnchor"></a>
                    <a class="token" href="#/s:9SwiftTerm12LocalProcessC14setHostLogging9directoryySSSg_tF">setHostLogging(directory:<wbr>)</a>
                    </code>
                  </div>
                  <div class="height-container">
                    <div class="pointer-container"></div>
                    <section class="section">
                      <div class="pointer"></div>
                      <div class="abstract">
                        <p>Use this method to toggle the logging of data coming from the host, or pass nil to stop</p>

                      </div>
                      <div class="declaration">
                        <h4>Declaration</h4>
                        <div class="language">
                          <p class="aside-title">Swift</p>
                          <pre class="highlight swift"><code><span class="kd">public</span> <span class="kd">func</span> <span class="nf">setHostLogging</span><span class="p">(</span><span class="nv">directory</span><span class="p">:</span> <span class="kt">String</span><span class="p">?)</span></code></pre>

                        </div>
                      </div>
                      <div>
                        <h4>Parameters</h4>
                        <table class="graybox">
                          <tbody>
                            <tr>
                              <td>
                                <code>
                                <em>directory</em>
                                </code>
                              </td>
                              <td>
                                <div>
                                  <p>location where the log files will be stored.</p>
                                </div>
                              </td>
                            </tr>
                          </tbody>
                        </table>
                      </div>
                      <div class="slightly-smaller">
                        <a href="https://github.com/migueldeicaza/SwiftTerm/tree/master/Sources/SwiftTerm/LocalProcess.swift#L211-L214">Show on GitHub</a>
                      </div>
                    </section>
                  </div>
                </li>
              </ul>
            </div>
          </section>
        </section>
        <section id="footer">
          <p>&copy; 2020 <a class="link" href="https://tirania.org/" target="_blank" rel="external">Miguel de Icaza</a>. All rights reserved. (Last updated: 2020-05-30)</p>
          <p>Generated by <a class="link" href="https://github.com/realm/jazzy" target="_blank" rel="external">jazzy ♪♫ v0.13.2</a>, a <a class="link" href="https://realm.io" target="_blank" rel="external">Realm</a> project.</p>
        </section>
      </article>
    </div>
  </body>
</div>
</html>
